package com.ztf.call;

import redis.clients.jedis.Jedis;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


@WebServlet("/addStudent")
public class AddStudent extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        Jedis jedis = new Jedis("localhost",6379);
        Long llen = jedis.llen("name");
        if (llen != 0){
            //一天只能更新一次班级成员
            return;
        }
        String name = request.getParameter("name");
        String[] split = name.split("#");
        for (String s : split) {
            Long name1 = jedis.lpush("name", s);
        }


        //设置过期时间
        jedis.expire("name",39600);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }

}
